package jwt

import (
	"gitee.com/youkelike/ziam/zctl/options"
	"gitee.com/youkelike/ziam/zctl/util/templates"
	"github.com/spf13/cobra"
)

var jwtLong = templates.LongDesc(`
	JWT command.

	This commands is used to sigin/show/verify jwt token.`)

func NewCmdJWT(f options.Factory, ioStreams options.IOStreams) *cobra.Command {
	cmd := &cobra.Command{
		Use:                   "jwt SUBCOMMAND",
		DisableFlagsInUseLine: true,
		Short:                 "JWT command-line tool",
		Long:                  jwtLong,
		Run:                   options.DefaultSubCommandRun(ioStreams.ErrOut),
	}

	// add subcommands
	cmd.AddCommand(NewCmdSign(f, ioStreams))   // 签发
	cmd.AddCommand(NewCmdShow(f, ioStreams))   // 展示 token 中的内容但不验证
	cmd.AddCommand(NewCmdVerify(f, ioStreams)) // 验证

	return cmd
}
